package demo3;

interface IShape{
    /*public static int a = 10;
    public abstract void draw();*/
    int a = 10; //接口当中 默认成员变量是public static
    void draw();//成员方法是 public abstarct修饰的
                //接口当中不能有普通方法
    /*defalut public void test(){ //java8开始 允许在接口中定义一个default方法
        System.out.println("test()");
    }*/
    public static void test2(){
        System.out.println("test2()");
    }
}
class Rect implements  IShape{
    @Override
    public void draw() {
        System.out.println("矩形");
    }
}
class Flower implements  IShape{
    @Override
    public void draw() {
        System.out.println("花");
    }
}
public class Test {
    public static void drawMap(IShape iShape){
        iShape.draw();
    }
    public static void main(String[] args) {
        //两种实现方式
        //IShape iShape = new IShape();
        //接口也可以实现向上转型和动态绑定
        IShape iShape1 = new Rect();
        IShape iShape2 = new Flower();
        drawMap(iShape1);
        drawMap(iShape2);
        //drawMap(new Rect());
        drawMap(new Rect());
        drawMap(new Flower());
    }
}
